﻿@model PaginationList<Note> 

@{
    ViewBag.Title = Resources.NoteList;
    Layout = "~/Views/Shared/_NoteLayout.cshtml";
}
<div id="content-inner-wrapper">
    <section id="main-content">
    @foreach (iHouse.Model.Data.Note note in this.Model)
    {
        <article class="post">
            <header class="postHeader">
                <div class="date">
                @if (note.CreatedDate.HasValue) { @note.CreatedDate.Value.ToString("MMM dd, yy") } -
                    <span>
                        @Html.NavigationLink(note.Category.Name, iHouse.Common.Const.ActionConst.NOTE_LIST, Enum.GetName(typeof(iHouse.Model.Data.CategoryType), iHouse.Model.Data.CategoryType.Note),
                             new { @category = note.Category.ID }, new { @i = "icon-folder-open-alt icon-large" })
                    </span>
                    @if (Request.IsAuthenticated)
                    {
                        <span>
                            <a class="noteDel" href="javascript:void(0)" onclick="HandleNoteDelete('@note.ID')"><i class="icon-trash icon-large"></i>@Resources.DeleteNoteAlt</a></span>
                    }
                </div>
                @if (Request.IsAuthenticated)
                {
                    <h2>@Html.ActionLink(note.Title, "Edit", new { @noteID = note.ID }, new { @class = "noteEdit" })</h2>
                }
                else
                {
                    <h2>@note.Title</h2>
                }
            </header>
            <section class="postText">
                <p>@note.Description</p>
                <p>@note.Reference</p>
            </section>
            <div class="sidebadge"></div>
        </article>
    }
    <div class="emm-paginate">
        <span class="emm-title">@Resources.NotePages</span>
        @{ViewData["prevclass"] = "emm-prev";
          ViewData["currentclass"] = "emm-page emm-current";
          ViewData["pageclass"] = "emm-page";
          ViewData["nextclass"] = "emm-next";
          }
        @Html.Partial("Pagination", Model, ViewData)
    </div>
    </section>
    <aside id="sidebar">
        <section id="socialIcons">
        </section>
        <section class="sideBox">
            <h3>@Resources.Categories</h3>
            <ul>           
            @foreach (iHouse.Model.Data.Category item in ViewBag.TypeCategories)
            {
                <li>@Html.ActionLink(item.Name, iHouse.Common.Const.ActionConst.NOTE_LIST, new System.Web.Routing.RouteValueDictionary(
                    new
                    {
                        controller = Enum.GetName(typeof(iHouse.Model.Data.CategoryType), iHouse.Model.Data.CategoryType.Note),
                        category = item.ID
                    }))</li>
            }      
            </ul>
        </section>
    </aside>
</div>
<script type="text/javascript">
    function HandleNoteDelete(id) {
        if ('@System.Threading.Thread.CurrentThread.CurrentUICulture.Name' == "zh-CN") {
            Sys.require(["iHouse.Culture.cn"]);
        }

        Sys.require(["NoteUI", "jqUI"], function () { DeleteNote(id); });
    }

    Sys.require(["NoteUI", "colorbox", "jQuery"], function () { InitNoteModals(); });    
</script>